package com.chuangke.flowable.service;

import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.chuangke.common.db.page.CkPageQuery;
import com.chuangke.flowable.model.FlowableFormModel;
import com.chuangke.flowable.model.FlowableFormViewModel;
import com.chuangke.flowable.model.FlowableHandler;
import com.chuangke.flowable.model.FlowableNode;

public interface FlowableService {
	
	/**
	 * 查询待办任务列表
	 * @return
	 */
	IPage<FlowableFormViewModel> findMyCreatedTask(CkPageQuery request) ;

	/**
	 * 查询待办任务列表
	 * @return
	 */
	IPage<FlowableFormViewModel> findTodoTask(CkPageQuery request) ;
	
	/**
	 * 查询已办任务
	 * @return
	 */
	IPage<FlowableFormViewModel> findDoneTask(CkPageQuery request) ;
	
	/**
	 * 查询已办结任务
	 * @return
	 */
	IPage<FlowableFormViewModel> findDownAndOverTask(CkPageQuery request) ;
	
	/**
	 * 查询退回任务
	 * @return
	 */
	IPage<FlowableFormViewModel> findRrejectTask(CkPageQuery request) ;
	
	
	/**
	 * 启动流程
	 * @param processDefinitionKey
	 * @param variables
	 * @return
	 */
	String startProcessInstance(String processDefinitionKey,FlowableHandler handler,Map<String, Object> variables) ;
	
	/**
	 * 启动流程
	 * @param processDefinitionKey
	 * @param variables
	 * @return
	 */
	String startProcessInstance(String processDefinitionKey,FlowableHandler handler,FlowableFormModel flowableFormModel,Map<String, Object> variables) ;
	
	/**
	 * 审批
	 * @param variables
	 */
	void complete(FlowableHandler handler,String message,Map<String, Object> variables) ;
	
	/**
	 * 异步审批
	 * @param handler
	 * @param message
	 * @param variables
	 * @return
	 */
	CompletableFuture<Map<String,String>> asyncComplete(FlowableHandler handler,String message,Map<String, Object> variables) ;
	
	/**
	 * 撤回
	 * @param handler
	 */
	void revoke(FlowableHandler handler) ;
	
	/**
	 * 退回
	 */
	void reject(FlowableHandler handler,String message,Map<String, Object> variables) ;
	
	/**
	 * 流程图
	 * @param businessKey
	 * @return
	 * @throws IOException
	 */
	byte[] generateImageByBusinessKey(String businessKey)  throws IOException;
	
	/**
	 * 查看流程节点
	 * @param businessKey
	 * @return
	 */
	List<FlowableNode> getFlowableNodeList(String businessKey) ;
	
	/**
	 * 删除流程实例
	 * @param businessKey
	 */
	void deleteProcessInstance(String businessKey) ;
}
